﻿package plugin.bagN.handler
{
    import com.core.*;
    import com.sh.game.util.*;
    import consts.*;
    import flash.external.*;
    import flash.geom.*;
    import flash.utils.*;
    import manager.*;
    import plugin.NewSkill.handler.*;
    import plugin.bagN.*;
    import pluginfw.nio.*;
    import pluginfw.nio.imsg.*;
    import view.*;
    import view.controller.*;
    import view.message.*;
    import view.sysNotice.*;
    import view.uilt.*;
    import vo.*;

    public class BagGroupHandler extends Object implements IGroupHandler
    {
        private var cfgFashion:Array;
        private var _needUpdate:Boolean = false;
        private var _cfgitems:Object;
        private var input:Input;
        private var _opentimeID:uint = 0;
        private var _sxtimeID:int = 0;
        private var _hastishi:Boolean = false;
        private var _curindex:int = 0;
        private var nowtime:Number = 0;
        private var _sxtimeID1:int = 0;
        private var _hastishi1:Boolean = false;
        private var _curindex1:int = 0;
        private var nowtime1:Number = 0;
        private var addItem:Object;
        private var cobj:Object;
        private var logcount:int = 0;
        private var guideFlag:Boolean = true;

        public function BagGroupHandler()
        {
            this.cfgFashion = ConfigDictionary.data.fashion;
            this._cfgitems = ConfigDictionary.data.item;
            this.input = new Input(null);
            this.cobj = new Object();
            setInterval(this.updatebagForPlugin, 1000);
            this.initUserArms();
            return;
        }// end function

        private function initUserArms() : void
        {
            var _loc_1:* = ModelProxy.getValue("data", "arms");
            var _loc_2:* = new Object();
            var _loc_3:int = 1;
            while (_loc_3 <= 205)
            {
                
                _loc_2[_loc_3] = this.changeSimpleArm(_loc_1[_loc_3]);
                _loc_3++;
            }
            ModelProxy.change("data", "arms", _loc_2);
            UserData.setData(UserDataType.Arms, _loc_2);
            return;
        }// end function

        private function updatebagForPlugin() : void
        {
            if (this._needUpdate)
            {
                ModelProxy.change("qianghua", "updateCompound", null);
                ModelProxy.change("armshow", "updatebag", null);
                ModelProxy.change("zbhc", "updatebag", null);
                ModelProxy.change("qianghua", "updatecost", null);
                ModelProxy.change("qianghua", "updatearm", null);
                ModelProxy.change("jianding", "updatearm", null);
                ModelProxy.change("yitianpidi", "updatecost", null);
                ModelProxy.change("wing", "addItem", null);
                ModelProxy.change("unionCreate", "updateBag", null);
                ModelProxy.change("unionDonate", "updateBag", null);
                ModelProxy.change("npcdialog", "updatebag", null);
                ModelProxy.change("mainui", "updateTFbyBag", null);
                ModelProxy.change("mainview", "shenlujiaobiao", null);
                this._needUpdate = false;
            }
            return;
        }// end function

        public function dealSimpleMessage(param1:ISimpleMessage) : void
        {
            var result:Object;
            var bagItems:Object;
            var item:Object;
            var cfgitem:Object;
            var obj:Object;
            var i:int;
            var j:int;
            var storeid:int;
            var maxcount:int;
            var po:Array;
            var eff:int;
            var eff3:int;
            var needchange:Boolean;
            var add:Array;
            var addarr:Array;
            var itemcfg:Object;
            var list:Object;
            var isdjqh:Boolean;
            var id:int;
            var timeObj:Object;
            var jyz:int;
            var effarr:Array;
            var p:Point;
            var poarr:Array;
            var newarr:Array;
            var curnum:int;
            var str:String;
            var vip:Object;
            var viplevel:int;
            var n:int;
            var m:int;
            var huanwu:Array;
            var arr1:Array;
            var obj2:Object;
            var num1:int;
            var fashions:Array;
            var arr:Array;
            var obj1:Object;
            var num:int;
            var hasget:Boolean;
            var name:String;
            var lv:int;
            var o:Object;
            var bag:Object;
            var k:int;
            var message:* = param1;
            switch(message.getCmd())
            {
                case CMDBag.Error:
                {
                    ModelProxy.change("movetips", "error", message.getParam());
                    ModelProxy.change("data", "itempoint", null);
                    break;
                }
                case CMDBag.Error2:
                {
                    storeid = message.getParam();
                    item = ObjectUtil.clone(ConfigDictionary.data.storeNew[storeid]);
                    cfgitem = ConfigDictionary.data.item[item.itemid];
                    item.icon = cfgitem.icon;
                    item.name1 = cfgitem.name;
                    if (item && item.itemid == "101")
                    {
                        DialogMgr.instance.open(AppDialog.FLYING, "使用该功能要消耗" + item.name1 + ",你的背包没有" + item.name1 + "是否购买");
                    }
                    else
                    {
                        Alert2.show(item.name1 + "不足前往购买", "", ["确认", "取消"], function (param1:int, param2:Object) : void
            {
                if (param1 == 0)
                {
                    DialogMgr.instance.open(AppDialog.SURE_BUY_STORE, item);
                }
                return;
            }// end function
            );
                    }
                    ModelProxy.change("data", "itempoint", null);
                    break;
                }
                case CMDBag.Error3:
                {
                    Alert2.show("元宝不足前往充值", "", ["确认", "取消"], function (param1:int, param2:Object) : void
            {
                if (param1 == 0)
                {
                    if (!ItemUilt.canpay)
                    {
                        ModelProxy.change("movetips", "error", "功能尚未开放，敬请期待");
                        return;
                    }
                    ExternalInterface.call("topay");
                }
                return;
            }// end function
            );
                    ModelProxy.change("data", "itempoint", null);
                    break;
                }
                case CMDBag.Init:
                {
                    bagItems = message.getParam();
                    i;
                    while (i <= bagItems.maxcount)
                    {
                        
                        item = bagItems[i];
                        if (item)
                        {
                            if (item[2] == 2)
                            {
                                item.index = i;
                                item[4] = this._cfgitems[item[0]];
                            }
                            else if (item[2] == 1)
                            {
                                item.index = i;
                                item[4] = this.changeSimpleArm(item[4]);
                            }
                        }
                        i = (i + 1);
                    }
                    if (bagItems.jifen > 0)
                    {
                        ModelProxy.change("mainui", "addBtn", "xunbaoshop");
                    }
                    ModelProxy.change("data", "bag", bagItems);
                    ModelProxy.change("bag", "init", bagItems);
                    UserData.initBag(bagItems);
                    ModelProxy.change("fastlist", "initBagItems", bagItems);
                    ModelProxy.change("mainview", "bagItemChange", null);
                    ModelProxy.change("leftTishi", "setbagcount", null);
                    ModelProxy.change("mainui", "checkDrug", null);
                    ModelProxy.change("leftTishi", "useJingYanZhu", null);
                    ModelProxy.change("mainui", "updateTFbyBag", null);
                    ModelProxy.change("mainuiInstance", "updateBag", null);
                    this.updateOpenBag();
                    this.updateTimeout();
                    ModelProxy.change("mainui", "wdsj", null);
                    ModelProxy.change("mainview", "updateGuanZhi", null);
                    ModelProxy.change("zone", "baginit", bagItems);
                    ModelProxy.change("mainview", "showBaoshiCount", null);
                    break;
                }
                case CMDBag.openBox:
                {
                    break;
                }
                case CMDBag.getRelive:
                {
                    ModelProxy.change("death", "showtime", message.getParam());
                    break;
                }
                case CMDBag.tidyItem:
                {
                    bagItems = message.getParam();
                    maxcount = UserData.getBagData("maxcount");
                    i;
                    while (i <= bagItems.maxcount)
                    {
                        
                        item = bagItems[i];
                        if (item)
                        {
                            if (item[2] == 2)
                            {
                                item[4] = this._cfgitems[item[0]];
                            }
                            else if (item[2] == 1)
                            {
                                item[4] = this.changeSimpleArm(item[4]);
                            }
                        }
                        i = (i + 1);
                    }
                    this.changeBag(bagItems, false, null, null, true);
                    ModelProxy.change("bag", "tidyItem", bagItems);
                    this.updateTimeout();
                    break;
                }
                case CMDBag.AddItem:
                {
                    result = message.getParam();
                    eff;
                    eff3;
                    if (result == null)
                    {
                        return;
                    }
                    if (result.eff == 4)
                    {
                        eff;
                        delete result["eff"];
                    }
                    else if (result.eff)
                    {
                        eff;
                        delete result["eff"];
                    }
                    else if (result.eff2)
                    {
                        eff;
                        delete result["eff2"];
                    }
                    if (result.eff3 == 1)
                    {
                        eff;
                        delete result["eff3"];
                    }
                    else if (result.eff3 == 2)
                    {
                        eff;
                        delete result["eff3"];
                    }
                    else if (result.eff3 == 4)
                    {
                        eff;
                        delete result["eff3"];
                    }
                    else if (result.eff3 == 6)
                    {
                        eff;
                        delete result["eff3"];
                    }
                    else if (result.eff3 == 7)
                    {
                        eff;
                        delete result["eff3"];
                    }
                    else if (result.eff3 == 8)
                    {
                        eff;
                        delete result["eff3"];
                    }
                    else if (result.eff3 == 9)
                    {
                        eff;
                        delete result["eff3"];
                    }
                    else if (result.eff4)
                    {
                        ModelProxy.change("mainui", "flyeff", result.eff4);
                        delete result["eff4"];
                    }
                    bagItems = this.Resetchangelist(result);
                    needchange = this.bagItemExcept(bagItems);
                    if (eff > 0)
                    {
                        add = new Array();
                    }
                    addarr = new Array();
                    this.changeBag(bagItems, true, add, addarr);
                    itemcfg = ConfigDictionary.data.item;
                    if (add && add.length > 0)
                    {
                        effarr = new Array();
                        var _loc_3:int = 0;
                        var _loc_4:* = add;
                        while (_loc_4 in _loc_3)
                        {
                            
                            j = _loc_4[_loc_3];
                            if (itemcfg[j])
                            {
                                if (int(itemcfg[j].icon) == 10007)
                                {
                                    continue;
                                }
                                p = ModelProxy.getValue("data", "itempoint");
                                if (eff == 4)
                                {
                                    if (itemcfg[j].itemid >= Constant.SUIJISHI1)
                                    {
                                        ModelProxy.change("skill", "setskill", null);
                                        effarr.push({icon:itemcfg[j].icon, itemid:itemcfg[j].itemid});
                                    }
                                    continue;
                                }
                                if (p != null)
                                {
                                    effarr.push({icon:itemcfg[j].icon, x:p.x, y:p.y});
                                    continue;
                                }
                                if (eff == 1)
                                {
                                    effarr.push({icon:itemcfg[j].icon});
                                    continue;
                                }
                                if (eff == 2)
                                {
                                    effarr.push({icon:itemcfg[j].icon, middle:true});
                                    continue;
                                }
                                if (eff == 3)
                                {
                                    effarr.push({icon:itemcfg[j].icon, qianghua:true});
                                    continue;
                                }
                                if (eff == 5)
                                {
                                    poarr = ModelProxy.getValue("data", "zaixiaopoint");
                                    i;
                                    while (i < poarr.length)
                                    {
                                        
                                        effarr[i] = {icon:poarr[i].icon, x:poarr[i].x, y:poarr[i].y};
                                        i = (i + 1);
                                    }
                                    continue;
                                }
                                if (eff == 6)
                                {
                                    po = ModelProxy.getValue("data", "qrylItemPoint");
                                    i;
                                    while (i < add.length)
                                    {
                                        
                                        effarr[i] = {icon:itemcfg[add[i]].icon, x:po[i].x, y:po[i].y};
                                        i = (i + 1);
                                    }
                                    continue;
                                }
                                if (eff == 7)
                                {
                                    po = ModelProxy.getValue("data", "scItemPoint");
                                    i;
                                    while (i < add.length)
                                    {
                                        
                                        effarr[i] = {icon:itemcfg[add[i]].icon, x:po[i].x, y:po[i].y};
                                        i = (i + 1);
                                    }
                                    continue;
                                }
                                if (eff == 8)
                                {
                                    po = ModelProxy.getValue("data", "mrlcItemPoint");
                                    i;
                                    while (i < add.length)
                                    {
                                        
                                        effarr[i] = {icon:itemcfg[add[i]].icon, x:po[i].x, y:po[i].y};
                                        i = (i + 1);
                                    }
                                    continue;
                                }
                                if (eff == 9)
                                {
                                    po = ModelProxy.getValue("data", "qditempoint");
                                    i;
                                    while (i < po.length)
                                    {
                                        
                                        effarr[i] = {icon:itemcfg[add[i]].icon, x:po[i].x, y:po[i].y};
                                        i = (i + 1);
                                    }
                                }
                            }
                        }
                        if (eff != 3)
                        {
                            ModelProxy.change("mainui", "itemEffect", effarr);
                        }
                        else
                        {
                            ModelProxy.change("mainui", "itemEffect3", effarr);
                        }
                    }
                    if (bagItems["movetips"] != 1 && addarr && addarr.length > 0)
                    {
                        if (this.addItem && int(this.addItem[4].itemtype) == 2 && int(this.addItem[4].cls) == 7 && int(this.addItem[4].autonopen) != 1)
                        {
                            DialogMgr.instance.open(AppDialog.HUODE_BOX, this.addItem);
                        }
                        else if (this.addItem && this.addItem[4].cls == 2 && this.addItem[4].buffertype == 102)
                        {
                            vip = ModelProxy.getValue("vip", "getvip");
                            viplevel = vip == null ? (0) : (vip.vipLevel);
                            if (viplevel == 0)
                            {
                                DialogMgr.instance.open(AppDialog.HUODE_BOX, this.addItem);
                                break;
                            }
                        }
                        else if (this.addItem)
                        {
                            n;
                            m;
                            if (this.addItem[0] == 242202016)
                            {
                                huanwu = ModelProxy.getValue("data", "huanwu");
                                var _loc_3:int = 0;
                                var _loc_4:* = this.cfgFashion;
                                while (_loc_4 in _loc_3)
                                {
                                    
                                    obj = _loc_4[_loc_3];
                                    if (int(obj.item) == this.addItem[4].itemid)
                                    {
                                        m = (m + 1);
                                        break;
                                    }
                                }
                                if (!huanwu && ItemUilt.getAllCount(this.addItem[4].itemid) == 1)
                                {
                                    m = (m + 1);
                                }
                                else
                                {
                                    arr1;
                                    var _loc_3:int = 0;
                                    var _loc_4:* = huanwu;
                                    while (_loc_4 in _loc_3)
                                    {
                                        
                                        obj2 = _loc_4[_loc_3];
                                        arr1[int(this.cfgFashion[obj2.fashionId].item)] = obj2;
                                    }
                                    num1 = ItemUilt.getAllCount(int(this.addItem[4].itemid));
                                    if (!arr1[int(this.addItem[4].itemid)] && num1 == 1)
                                    {
                                        m = (m + 1);
                                    }
                                }
                                if (m == 2)
                                {
                                    DialogMgr.instance.open(AppDialog.HUODE_BOX, this.addItem);
                                }
                            }
                            else
                            {
                                fashions = ModelProxy.getValue("data", "fashion");
                                var _loc_3:int = 0;
                                var _loc_4:* = this.cfgFashion;
                                while (_loc_4 in _loc_3)
                                {
                                    
                                    obj = _loc_4[_loc_3];
                                    if (int(obj.item) == this.addItem[4].itemid)
                                    {
                                        n = (n + 1);
                                        break;
                                    }
                                }
                                if (!fashions && ItemUilt.getAllCount(this.addItem[4].itemid) == 1)
                                {
                                    n = (n + 1);
                                }
                                else
                                {
                                    arr;
                                    var _loc_3:int = 0;
                                    var _loc_4:* = fashions;
                                    while (_loc_4 in _loc_3)
                                    {
                                        
                                        obj1 = _loc_4[_loc_3];
                                        arr[int(this.cfgFashion[obj1.fashionId].item)] = obj1;
                                    }
                                    num = ItemUilt.getAllCount(int(this.addItem[4].itemid));
                                    if (!arr[int(this.addItem[4].itemid)] && num == 1)
                                    {
                                        n = (n + 1);
                                    }
                                }
                                if (n == 2)
                                {
                                    DialogMgr.instance.open(AppDialog.HUODE_BOX, this.addItem);
                                }
                            }
                        }
                        newarr;
                        i;
                        while (i < addarr.length)
                        {
                            
                            if (addarr[i] is Array)
                            {
                                hasget;
                                j;
                                while (j < newarr.length)
                                {
                                    
                                    if (newarr[j][0] == addarr[i][0])
                                    {
                                        newarr[j][1] = newarr[j][1] + addarr[i][1];
                                        hasget;
                                        break;
                                    }
                                    j = (j + 1);
                                }
                                if (!hasget)
                                {
                                    newarr.push([addarr[i][0], addarr[i][1]]);
                                }
                            }
                            i = (i + 1);
                        }
                        curnum;
                        str;
                        i;
                        while (i < newarr.length)
                        {
                            
                            name = (itemcfg[newarr[i][0]].name as String).substr(2);
                            if (newarr[i][0] == 240102100 || name == "玉佩")
                            {
                            }
                            else
                            {
                                curnum = (curnum + 1);
                                if (i == (newarr.length - 1))
                                {
                                    if (newarr[i][0] == 3)
                                    {
                                        WarningManager.show(59, [newarr[i][1]]);
                                    }
                                    else
                                    {
                                        str = str + (itemcfg[newarr[i][0]].name + "*" + newarr[i][1]);
                                    }
                                }
                                else
                                {
                                    str = str + (itemcfg[newarr[i][0]].name + "*" + newarr[i][1] + ",");
                                }
                                if (curnum == 5)
                                {
                                    ModelProxy.change("movetips", "error1", {data:str, color:MColor.New62});
                                    str;
                                    curnum;
                                }
                            }
                            i = (i + 1);
                        }
                        if (str != "获得")
                        {
                            ModelProxy.change("movetips", "error1", {data:str, color:MColor.New62});
                        }
                    }
                    ModelProxy.change("bag", "addItem", bagItems);
                    ModelProxy.change("fastlist", "updatetool", bagItems);
                    ModelProxy.change("mainuiInstance", "updateBag", null);
                    if (bagItems == null)
                    {
                        return;
                    }
                    if (needchange)
                    {
                        lv = ModelProxy.getValue("data", "user.level");
                        if (lv >= 60)
                        {
                            DialogMgr.instance.open(AppDialog.COMPOUND_TIP);
                        }
                        this._needUpdate = true;
                        this.updateTimeout();
                    }
                    if (result.hasOwnProperty("treasurehouseexp"))
                    {
                        ModelProxy.change("shenzhuang", "updatebag", result);
                    }
                    ModelProxy.change("data", "itempoint", null);
                    ModelProxy.change("fashen", "showSuiPian", null);
                    ModelProxy.change("baoshi", "addItem", null);
                    ModelProxy.change("fashen", "updateJinbi", null);
                    ModelProxy.change("xunbao", "updatecost", null);
                    ModelProxy.change("mainview", "showWingCount", null);
                    ModelProxy.change("role", "showBaoshiCount", null);
                    ModelProxy.change("mainview", "showBaoshiCount", null);
                    ModelProxy.change("bossChallenge", "updateFBJZ", null);
                    break;
                }
                case CMDBag.AddItemList:
                {
                    list = message.getParam();
                    if (list)
                    {
                        var _loc_3:int = 0;
                        var _loc_4:* = list.source;
                        while (_loc_4 in _loc_3)
                        {
                            
                            o = _loc_4[_loc_3];
                            this.changeBag(o);
                            ModelProxy.change("bag", "addItem", o);
                            ModelProxy.change("fastlist", "updatetool", o);
                        }
                    }
                    if (UserData.getUserData("level") >= 60)
                    {
                        DialogMgr.instance.open(AppDialog.COMPOUND_TIP);
                    }
                    ModelProxy.change("qianghua", "updatearm", null);
                    ModelProxy.change("jianding", "updatearm", null);
                    ModelProxy.change("qianghua", "updatecost", null);
                    this.updateTimeout();
                    break;
                }
                case CMDBag.Swap:
                {
                    bagItems = this.Resetchangelist(message.getParam());
                    isdjqh = ModelProxy.getValue("data", "isdjqh");
                    if (isdjqh)
                    {
                        ModelProxy.change("data", "isdjqh", false);
                        bag = UserData.getBagData();
                        k;
                        while (k <= bag.maxcount)
                        {
                            
                            if (bagItems[k])
                            {
                                ModelProxy.change("qhtips", "data", bagItems[k][4]);
                                break;
                            }
                            k = (k + 1);
                        }
                    }
                    this.changeBag(bagItems, false);
                    ModelProxy.change("qianghua", "updatearm", null);
                    ModelProxy.change("jianding", "updatearm", null);
                    ModelProxy.change("bag", "addItem", bagItems);
                    ModelProxy.change("fastlist", "updatetool", bagItems);
                    ModelProxy.change("armshow", "updatebag", null);
                    ModelProxy.change("union", "updateBag", null);
                    ModelProxy.change("specialActivity", "updateBag", null);
                    ModelProxy.change("mainui", "updateBagForActvieBtn", null);
                    ModelProxy.change("store", "refresh", null);
                    ModelProxy.change("mainui", "checkXunbaoShop", null);
                    ModelProxy.change("zbhc", "updatebag", null);
                    ModelProxy.change("ring", "updatebag", null);
                    ModelProxy.change("yitianpidi", "updatecost", null);
                    ModelProxy.change("mainview", "bagItemChange", null);
                    ModelProxy.change("leftTishi", "setbagcount", null);
                    ModelProxy.change("mainui", "checkDrug", null);
                    ModelProxy.change("leftTishi", "useJingYanZhu", null);
                    if (UserData.getUserData("level") >= 60)
                    {
                        DialogMgr.instance.open(AppDialog.COMPOUND_TIP);
                    }
                    this.updateTimeout();
                    break;
                }
                case CMDBag.Error:
                {
                    ModelProxy.change("movetips", "error", message.getParam());
                    break;
                }
                case CMDBag.Tbag:
                {
                    ModelProxy.change("bag", "gettab", message.getParam());
                    break;
                }
                case CMDBag.UpdateFcm:
                {
                    if (int(message.getParam()) == 1 || int(message.getParam()) == 2)
                    {
                        Fcmalert.show(int(message.getParam()));
                    }
                    ModelProxy.change("data", "bag.fcmstate", message.getParam());
                    break;
                }
                case CMDBag.UseItem:
                {
                    id = message.getParam();
                    ModelProxy.change("fastlist", "cd", message.getParam());
                    ModelProxy.change("bag", "toolstartcd", message.getParam());
                    timeObj = ModelProxy.getValue("data", "toolcd");
                    timeObj[id] = getTimer() + int(this._cfgitems[id].usecd) * 1000;
                    ModelProxy.change("data", "settoolid", id);
                    break;
                }
                case CMDBag.UseJingYanZhu:
                {
                    jyz = UserData.getOnlineData("jyz");
                    ModelProxy.change("movetips", "error", "剩余经验珠使用次数:" + (10 - jyz));
                    ModelProxy.change("mainui", "wdsj", null);
                    break;
                }
                case CMDBag.DigResult:
                {
                    result = message.getParam();
                    ModelProxy.change("mainuiInstance", "updateMining", result);
                    break;
                }
                case CMDBag.openBoxResult:
                {
                    ModelProxy.change("qingtongbox", "result", message.getParam());
                    break;
                }
                default:
                {
                    break;
                }
            }
            ModelProxy.change("mainview", "shenlujiaobiao", null);
            return;
        }// end function

        public function dealBufferMessage(param1:IBufferMessage) : void
        {
            var _loc_3:Input = null;
            var _loc_5:int = 0;
            var _loc_6:int = 0;
            var _loc_2:* = new Object();
            _loc_3 = new Input(null);
            var _loc_4:* = param1.getBody();
            param1.getBody().position = 0;
            _loc_3.setBytes(_loc_4);
            switch(param1.getCmd())
            {
                case CMDBag.Error:
                {
                    _loc_2.byteValue = _loc_3.readByte();
                    _loc_2.testBean = new Array();
                    _loc_5 = _loc_3.readVarInt(false);
                    _loc_6 = 0;
                    while (_loc_6 < _loc_5)
                    {
                        
                        _loc_2.testBean[_loc_6].byteValue = _loc_3.readByte();
                        _loc_2.testBean[_loc_6].shortValue = _loc_3.readShort();
                        _loc_2.testBean[_loc_6].intValue = _loc_3.readVarInt(true);
                        _loc_2.testBean[_loc_6].intValue = _loc_3.readVarInt(true);
                        _loc_2.testBean[_loc_6].intValue = _loc_3.readVarInt(true);
                        _loc_2.testBean[_loc_6].intValue = _loc_3.readVarInt(true);
                        _loc_2.testBean[_loc_6].intValue = _loc_3.readVarInt(true);
                        _loc_2.testBean[_loc_6].intValue = _loc_3.readVarInt(true);
                        _loc_2.testBean[_loc_6].longValue = _loc_3.readLong();
                        _loc_2.testBean[_loc_6].longValue = _loc_3.readLong();
                        _loc_2.testBean[_loc_6].longValue = _loc_3.readLong();
                        _loc_2.testBean[_loc_6].longValue = _loc_3.readLong();
                        _loc_2.testBean[_loc_6].longValue = _loc_3.readLong();
                        _loc_2.testBean[_loc_6].longValue = _loc_3.readLong();
                        _loc_2.testBean[_loc_6].stringValue = _loc_3.readString();
                        _loc_6++;
                    }
                    _loc_2.intValue = _loc_3.readVarInt(true);
                    break;
                }
                case CMDBag.ResChangeJuLingZhu:
                {
                    _loc_2.remainKillNum = _loc_3.readVarInt(false);
                    ModelProxy.change("bufferView", "juling", _loc_2.remainKillNum);
                    break;
                }
                case CMDBag.JuHunZhu:
                {
                    _loc_2.id = _loc_3.readVarInt(false);
                    _loc_2.state = _loc_3.readVarInt(false);
                    _loc_2.exp = _loc_3.readVarInt(false);
                    if (int(_loc_2.state) == 1)
                    {
                        ModelProxy.change("mainui", "updatejhz", _loc_2);
                    }
                    else
                    {
                        ModelProxy.change("mainui", "removeBtn", "juhunzhu");
                    }
                    break;
                }
                default:
                {
                    break;
                }
            }
            return;
        }// end function

        public function dealProxyMessage(param1:IProxyMessage) : void
        {
            return;
        }// end function

        private function bagItemExcept(param1:Object) : Boolean
        {
            var _loc_4:String = null;
            var _loc_5:Object = null;
            var _loc_6:Object = null;
            var _loc_2:Boolean = false;
            var _loc_3:* = UserData.getBagData();
            for (_loc_4 in param1)
            {
                
                _loc_5 = param1[_loc_4];
                if (int(_loc_4) >= 1 && int(_loc_4) <= int(_loc_3.maxcount))
                {
                    if (_loc_5 == null)
                    {
                        _loc_6 = _loc_3[_loc_4];
                        if (_loc_6 && _loc_6[2] == 2)
                        {
                            if (_loc_6[0] == 2212257)
                            {
                                _loc_2 = false;
                            }
                            else if (this._cfgitems[_loc_6[0]] && this._cfgitems[_loc_6[0]].cls == 1)
                            {
                                _loc_2 = false;
                            }
                            else
                            {
                                return true;
                            }
                        }
                        else
                        {
                            return true;
                        }
                        continue;
                    }
                    if (_loc_5 && _loc_5[2] == 2)
                    {
                        if (_loc_5[0] == 2212257)
                        {
                            _loc_2 = false;
                        }
                        else if (this._cfgitems[_loc_5[0]] && this._cfgitems[_loc_5[0]].cls == 1)
                        {
                            _loc_2 = false;
                        }
                        else
                        {
                            return true;
                        }
                        continue;
                    }
                    return true;
                }
            }
            return _loc_2;
        }// end function

        private function Resetchangelist(param1:Object) : Object
        {
            var _loc_5:Object = null;
            var _loc_6:Object = null;
            var _loc_7:String = null;
            if (param1 == null)
            {
                return null;
            }
            var _loc_2:* = UserData.getBagData();
            if (_loc_2 == null)
            {
                return null;
            }
            var _loc_3:* = _loc_2.maxcount;
            var _loc_4:* = new Object();
            if (param1.hasOwnProperty("maxcount"))
            {
                _loc_3 = param1.maxcount;
            }
            for (_loc_7 in param1)
            {
                
                _loc_5 = param1[_loc_7];
                if (int(_loc_7) >= 1 && int(_loc_7) <= _loc_3)
                {
                    if (_loc_5 && _loc_5[2] == 1)
                    {
                        if (_loc_5[4].hasOwnProperty("itemid"))
                        {
                            _loc_4[_loc_7] = _loc_5;
                        }
                        else
                        {
                            _loc_5[4] = this.changeSimpleArm(_loc_5[4]);
                        }
                    }
                }
                _loc_4[_loc_7] = _loc_5;
            }
            return _loc_4;
        }// end function

        private function changeSimpleArm(param1:Object) : Object
        {
            if (param1 == null)
            {
                return null;
            }
            var _loc_2:* = ItemObject.create(this._cfgitems[param1[1]]);
            _loc_2.id = int(param1[0]);
            _loc_2.superlevel = int(param1[2]);
            _loc_2.totalupvalue = int(param1[3]);
            _loc_2.upvalue = int(param1[4]);
            _loc_2.xq = param1[5];
            _loc_2.zs = int(param1[6]);
            _loc_2.luck = int(param1[7]);
            _loc_2.bind = int(param1[8]);
            _loc_2.appraisal = param1[9];
            _loc_2.timeout = Number(param1[10]);
            return _loc_2;
        }// end function

        private function updateOpenBag() : void
        {
            var _loc_1:* = UserData.getBagData();
            if (this._opentimeID > 0)
            {
                SecondTimerUtil.instance.removeTask(this._opentimeID);
                this._opentimeID = 0;
            }
            var _loc_2:* = _loc_1.maxcount;
            if (_loc_2 >= 98)
            {
                return;
            }
            this._opentimeID = SecondTimerUtil.instance.addSecondTask(this.setopentime);
            ModelProxy.change("bag", "updateopentime", null);
            return;
        }// end function

        private function setopentime() : void
        {
            var _loc_1:* = UserData.getBagData();
            var _loc_2:* = ModelProxy.getValue("vip", "getvip");
            (_loc_1.opentime + 1);
            var _loc_3:* = _loc_1.maxcount;
            var _loc_4:* = _loc_3 - 49 + 1;
            var _loc_5:Number = 1;
            if (_loc_2.privilegeCardLevel > 0)
            {
                switch(_loc_2.privilegeCardLevel)
                {
                    case 1:
                    {
                        _loc_5 = 1.5;
                        break;
                    }
                    case 2:
                    {
                        _loc_5 = 2;
                        break;
                    }
                    case 3:
                    {
                        _loc_5 = 3;
                    }
                    default:
                    {
                        break;
                    }
                }
            }
            var _loc_6:* = 4 * 60 / _loc_5;
            var _loc_7:* = _loc_4 * _loc_6;
            if (_loc_4 * _loc_6 <= _loc_1.opentime)
            {
                PluginManager.instance.sendToServer("bag", CMDBag.Expansion, {type:0, count:1});
                return;
            }
            return;
        }// end function

        private function updateTimeout() : void
        {
            var _loc_5:Object = null;
            if (this._hastishi)
            {
                return;
            }
            if (this._sxtimeID > 0)
            {
                SecondTimerUtil.instance.removeTask(this._sxtimeID);
                this._sxtimeID = 0;
            }
            this._curindex = 0;
            this.nowtime = 0;
            if (this._sxtimeID1 > 0)
            {
                SecondTimerUtil.instance.removeTask(this._sxtimeID1);
                this._sxtimeID1 = 0;
            }
            this._curindex1 = 0;
            this.nowtime1 = 0;
            var _loc_1:* = UserData.getBagData();
            var _loc_2:* = _loc_1.maxcount;
            var _loc_3:* = ModelProxy.getValue("data", "servertime") + Number(getTimer());
            var _loc_4:int = 1;
            while (_loc_4 <= _loc_2)
            {
                
                _loc_5 = _loc_1[_loc_4];
                if (_loc_5 && _loc_5[2] == 2 && _loc_5[3] > 0 && _loc_5[4] && _loc_5[4].cls != 4)
                {
                    if (_loc_5[3] - _loc_3 < 3600000)
                    {
                        if (_loc_5[3] >= _loc_3)
                        {
                            if (this.nowtime1 == 0 || this.nowtime1 > _loc_5[3])
                            {
                                this._curindex1 = _loc_4;
                                this.nowtime1 = _loc_5[3];
                            }
                        }
                    }
                    else if (this.nowtime == 0 || this.nowtime > _loc_5[3])
                    {
                        this.nowtime = _loc_5[3];
                        this._curindex = _loc_4;
                    }
                }
                _loc_4++;
            }
            if (this._curindex > 0)
            {
                this._sxtimeID = SecondTimerUtil.instance.addSecondTask(this.goudate);
            }
            if (this._curindex1 > 0)
            {
                this._sxtimeID1 = SecondTimerUtil.instance.addSecondTask(this.goudate2);
            }
            return;
        }// end function

        private function goudate2() : void
        {
            var _loc_4:Object = null;
            var _loc_1:* = UserData.getBagData();
            var _loc_2:* = (ModelProxy.getValue("data", "servertime") + Number(getTimer())) / 1000;
            var _loc_3:* = int(this.nowtime1 / 1000) - _loc_2;
            if (_loc_3 == 0)
            {
                ModelProxy.change("mainui", "gantanhao", "guoshi");
                _loc_4 = new Object();
                _loc_4.data = _loc_1[this._curindex1][4];
                _loc_4.tips1 = MColor.getHMTL("您背包里的" + _loc_1[this._curindex1][4].name + "道具已经过期。", 16);
                _loc_4.tips2 = "";
                _loc_4.closefun = this.closefunc;
                ModelProxy.change("mainui", "guoshiInfo", _loc_4);
                this._hastishi = true;
                if (this._sxtimeID1 > 0)
                {
                    SecondTimerUtil.instance.removeTask(this._sxtimeID1);
                    this._sxtimeID1 = 0;
                }
            }
            return;
        }// end function

        private function goudate() : void
        {
            var _loc_4:Object = null;
            var _loc_1:* = UserData.getBagData();
            var _loc_2:* = (ModelProxy.getValue("data", "servertime") + Number(getTimer())) / 1000;
            var _loc_3:* = int(this.nowtime / 1000) - _loc_2;
            if (_loc_3 == 3600)
            {
                ModelProxy.change("mainui", "gantanhao", "onehour");
                _loc_4 = new Object();
                _loc_4.data = _loc_1[this._curindex][4];
                _loc_4.tips1 = MColor.getHMTL("您背包里的" + _loc_1[this._curindex][4].name + "道具再过60分钟就要过期了。", 16);
                _loc_4.tips2 = MColor.getHMTL("温馨提醒：", 9) + MColor.getHMTL("请在过期前使用掉哦，不然你就失去他了哦", 16);
                _loc_4.closefun = this.closefunc;
                ModelProxy.change("mainui", "guoshiInfo", _loc_4);
                this._hastishi = true;
                if (this._sxtimeID > 0)
                {
                    SecondTimerUtil.instance.removeTask(this._sxtimeID);
                    this._sxtimeID = 0;
                }
            }
            return;
        }// end function

        private function closefunc() : void
        {
            this._hastishi = false;
            return;
        }// end function

        private function changeBag(param1:Object, param2:Boolean = true, param3:Array = null, param4:Array = null, param5:Boolean = false) : void
        {
            var dis:int;
            var olditem:Object;
            var key:String;
            var i:int;
            var item:Object;
            var obj:Object;
            var cfg:Object;
            var value:* = param1;
            var change:* = param2;
            var arr:* = param3;
            var addarr:* = param4;
            var changeAll:* = param5;
            var bag:* = UserData.getBagData();
            var now:* = getTimer();
            var flag:Boolean;
            var moneyChange:Object;
            this.logcount = 0;
            if (changeAll)
            {
                i;
                while (i <= bag.maxcount)
                {
                    
                    if (!value[i])
                    {
                        value[i] = null;
                    }
                    i = (i + 1);
                }
            }
            var _loc_7:int = 0;
            var _loc_8:* = value;
            while (_loc_8 in _loc_7)
            {
                
                key = _loc_8[_loc_7];
                if (key == "bonus")
                {
                    this.updateCost(2, value[key], change, arr, addarr);
                    moneyChange;
                    continue;
                }
                if (key == "gold")
                {
                    this.updateCost(1, value[key], change, arr, addarr);
                    continue;
                }
                if (key == "money")
                {
                    this.updateCost(3, value[key], change, arr, addarr);
                    ModelProxy.change("shenlu", "shenluYB", null);
                    moneyChange;
                    continue;
                }
                if (key == "bgold")
                {
                    this.updateCost(4, value[key], change, arr, addarr);
                    continue;
                }
                if (key == "jifen")
                {
                    dis = value[key] - int(bag.jifen);
                    if (dis > 0)
                    {
                        WarningManager.show(16, ["寻宝积分", "+" + dis, value[key]]);
                    }
                    else if (dis < 0)
                    {
                        WarningManager.show(16, ["寻宝积分", dis, value[key]]);
                    }
                    this.updateCost(5, value[key], change, arr, addarr);
                    moneyChange;
                    continue;
                }
                if (key == "zuoqi")
                {
                    this.updateCost(9, value[key], change, arr, addarr);
                    ModelProxy.change("mainui", "wdzq", null);
                    ModelProxy.change("mainui", "wdgd", null);
                    continue;
                }
                if (key == "yuyi")
                {
                    this.updateCost(10, value[key], change, arr, addarr);
                    ModelProxy.change("mainui", "wdyy", null);
                    ModelProxy.change("mainui", "wdgd", null);
                    continue;
                }
                if (key == "intel")
                {
                    this.updateCost(6, value[key], change, arr, addarr);
                    continue;
                }
                if (key == "eggs")
                {
                    bag.eggs = value[key];
                    ModelProxy.change("xunbao", "updatecost", null);
                    continue;
                }
                if (key == "atkchip")
                {
                    dis = value[key] - int(bag.atkchip);
                    if (dis > 0)
                    {
                        WarningManager.show(16, ["宝石碎片", "+" + dis, value[key]]);
                    }
                    else if (dis < 0)
                    {
                        WarningManager.show(16, ["宝石碎片", dis, value[key]]);
                    }
                    bag.atkchip = value[key];
                    ModelProxy.change("shenlu", "updateatkchipMSG", value[key]);
                    continue;
                }
                if (key == "defchip")
                {
                    dis = value[key] - int(bag.defchip);
                    if (dis > 0)
                    {
                        WarningManager.show(16, ["护盾碎片", "+" + dis, value[key]]);
                    }
                    else if (dis < 0)
                    {
                        WarningManager.show(16, ["护盾碎片", dis, value[key]]);
                    }
                    bag.defchip = value[key];
                    ModelProxy.change("shenlu", "updatedefchipMSG", value[key]);
                    continue;
                }
                if (key == "hpchip")
                {
                    dis = value[key] - int(bag.hpchip);
                    if (dis > 0)
                    {
                        WarningManager.show(16, ["血符碎片", "+" + dis, value[key]]);
                    }
                    else if (dis < 0)
                    {
                        WarningManager.show(16, ["血符碎片", dis, value[key]]);
                    }
                    bag.hpchip = value[key];
                    ModelProxy.change("shenlu", "updatehpchipMSG", value[key]);
                    continue;
                }
                if (key == "crichip")
                {
                    dis = value[key] - int(bag.crichip);
                    if (dis > 0)
                    {
                        WarningManager.show(16, ["魂珠碎片", "+" + dis, value[key]]);
                    }
                    else if (dis < 0)
                    {
                        WarningManager.show(16, ["魂珠碎片", dis, value[key]]);
                    }
                    bag.crichip = value[key];
                    ModelProxy.change("shenlu", "updatecrichipMSG", value[key]);
                    continue;
                }
                if (key == "opentime")
                {
                    bag.opentime = value[key];
                    this.updateOpenBag();
                    continue;
                }
                if (key == "recy")
                {
                    bag.recy = value[key];
                    ModelProxy.change("zbhuishou", "updateRecy", value[key]);
                    ModelProxy.change("jifenstore", "update", value[key]);
                    ModelProxy.change("jifenshop", "update", value[key]);
                    ModelProxy.change("mainui", "wdjf", null);
                    ModelProxy.change("mainui", "wdgd", null);
                    continue;
                }
                if (key == "tbag")
                {
                    continue;
                }
                if (key == "maxcount")
                {
                    bag.maxcount = value[key];
                    continue;
                }
                if (key == "emptycount")
                {
                    bag.emptycount = value[key];
                    continue;
                }
                if (key == "bmoney")
                {
                    bag.bmoney = value[key];
                    continue;
                }
                if (key == "fmoney")
                {
                    bag.fmoney = value[key];
                    continue;
                }
                if (key == "honor")
                {
                    dis = value[key] - int(bag.honor);
                    if (dis > 0)
                    {
                        ModelProxy.change("mainui", "addRongYu", dis);
                        ModelProxy.change("mainui", "logview", "获得  " + dis + "荣誉值");
                    }
                    ModelProxy.change("data", "bag.honor", value[key]);
                    ModelProxy.change("guanwei", "honor", value[key]);
                    continue;
                }
                if (key == "shengwang")
                {
                    dis = value[key] - int(bag.shengwang);
                    if (dis > 0)
                    {
                        WarningManager.show(16, ["声望", "+" + dis, value[key]]);
                        this.cobj.name = this._cfgitems[11].name;
                        this.cobj.count = dis;
                        this.cobj.itemid = this._cfgitems[11].itemid;
                        this.cobj.type = 1;
                        this.cobj.quality = this._cfgitems[11].quality;
                        this.logShow(this.cobj);
                    }
                    else if (dis < 0)
                    {
                        WarningManager.show(16, ["声望", dis, value[key]]);
                    }
                    bag.shengwang = value[key];
                    ModelProxy.change("goddess", "updateBag", null);
                    ModelProxy.change("guanwei", "shengwang", null);
                    continue;
                }
                if (key == "flyuppower")
                {
                    this.updateCost(23, value[key], change, arr, addarr);
                    continue;
                }
                if (key == "contribution")
                {
                    dis = value[key] - bag.contribution;
                    if (dis > 0)
                    {
                        this.cobj.name = this._cfgitems[5].name;
                        this.cobj.count = dis;
                        this.cobj.itemid = this._cfgitems[5].itemid;
                        this.cobj.type = 1;
                        this.cobj.quality = this._cfgitems[5].quality;
                        this.logShow(this.cobj);
                        WarningManager.show(16, ["贡献度", "+" + dis, value[key]]);
                    }
                    else if (dis < 0)
                    {
                        this.cobj.name = this._cfgitems[5].name;
                        this.cobj.count = dis;
                        this.cobj.itemid = this._cfgitems[5].itemid;
                        this.cobj.type = 2;
                        this.cobj.quality = this._cfgitems[5].quality;
                        this.logShow(this.cobj);
                        WarningManager.show(16, ["贡献度", dis, value[key]]);
                    }
                    bag.contribution = value[key];
                    ModelProxy.change("union", "updateContribution", null);
                    continue;
                }
                if (int(key) >= 1 && int(key) <= int(bag.maxcount))
                {
                    item = value[key];
                    if (item == null)
                    {
                        if (change)
                        {
                            olditem = bag[key];
                            if (olditem && olditem[4])
                            {
                                this.cobj.name = olditem[4].name;
                                this.cobj.count = olditem[1];
                                this.cobj.itemid = olditem[4].itemid;
                                this.cobj.type = 2;
                                this.cobj.quality = olditem[4].quality;
                                this.logShow(this.cobj);
                            }
                        }
                        obj = new Object();
                        obj.index = key;
                        obj.lock = 0;
                        bag[key] = obj;
                        if (olditem && olditem[4] && olditem[4].itemtype == 2 && olditem[4].cls == 4 && olditem[4].bind != 1)
                        {
                            ModelProxy.change("mainui", "wdsj", null);
                            return;
                        }
                        flag;
                        continue;
                    }
                    if (change)
                    {
                        olditem = bag[key];
                        if (olditem && olditem[4])
                        {
                            if (olditem[0] == item[0])
                            {
                                if (olditem[1] > item[1])
                                {
                                    this.cobj.name = olditem[4].name;
                                    this.cobj.count = olditem[1] - item[1];
                                    this.cobj.itemid = olditem[4].itemid;
                                    this.cobj.type = 2;
                                    this.cobj.quality = olditem[4].quality;
                                    this.logShow(this.cobj);
                                }
                                else if (olditem[1] < item[1])
                                {
                                    if (item[0] == 240102100)
                                    {
                                        ModelProxy.change("movetips", "error", "系统检测到气血石，已经帮您自动使用");
                                        PluginManager.instance.sendToServer("bag", CMDBag.UseItem, key);
                                    }
                                    else
                                    {
                                        this.cobj.name = olditem[4].name;
                                        this.cobj.count = item[1] - olditem[1];
                                        this.cobj.itemid = olditem[4].itemid;
                                        this.cobj.type = 1;
                                        this.cobj.quality = olditem[4].quality;
                                        this.logShow(this.cobj);
                                    }
                                    if (arr)
                                    {
                                        arr.push(olditem[4].itemid);
                                    }
                                    if (addarr)
                                    {
                                        addarr.push([olditem[4].itemid, item[1] - olditem[1]]);
                                    }
                                }
                            }
                            else
                            {
                                this.cobj.name = olditem[4].name;
                                this.cobj.count = olditem[1];
                                this.cobj.itemid = olditem[4].itemid;
                                this.cobj.type = 2;
                                this.cobj.quality = olditem[4].quality;
                                this.logShow(this.cobj);
                                if (item[4])
                                {
                                    if (item[0] == 240102100)
                                    {
                                        ModelProxy.change("movetips", "error", "系统检测到气血石，已经帮您自动使用");
                                        PluginManager.instance.sendToServer("bag", CMDBag.UseItem, key);
                                    }
                                    else
                                    {
                                        this.cobj.name = item[4].name;
                                        this.cobj.count = item[1];
                                        this.cobj.itemid = item[4].itemid;
                                        this.cobj.type = 1;
                                        this.cobj.quality = item[4].quality;
                                        this.logShow(this.cobj);
                                    }
                                    if (arr)
                                    {
                                        arr.push(item[4].itemid);
                                    }
                                    if (addarr)
                                    {
                                        addarr.push([item[4].itemid, item[1]]);
                                    }
                                }
                                else if (this._cfgitems[item[0]])
                                {
                                    if (item[0] == 240102100)
                                    {
                                        ModelProxy.change("movetips", "error", "系统检测到气血石，已经帮您自动使用");
                                        PluginManager.instance.sendToServer("bag", CMDBag.UseItem, key);
                                    }
                                    this.cobj.name = this._cfgitems[item[0]].name;
                                    this.cobj.count = item[1];
                                    this.cobj.itemid = this._cfgitems[item[0]].itemid;
                                    this.cobj.type = 1;
                                    this.cobj.quality = this._cfgitems[item[0]].quality;
                                    this.logShow(this.cobj);
                                    if (arr)
                                    {
                                        arr.push(this._cfgitems[item[0]].itemid);
                                    }
                                    if (addarr)
                                    {
                                        addarr.push([this._cfgitems[item[0]].itemid, item[1]]);
                                    }
                                }
                            }
                        }
                        else if (item[4])
                        {
                            if (item[0] == 240102100)
                            {
                                ModelProxy.change("movetips", "error", "系统检测到气血石，已经帮您自动使用");
                                PluginManager.instance.sendToServer("bag", CMDBag.UseItem, key);
                            }
                            this.cobj.name = item[4].name;
                            this.cobj.count = item[1];
                            this.cobj.itemid = item[4].itemid;
                            this.cobj.type = 1;
                            this.cobj.quality = item[4].quality;
                            this.logShow(this.cobj);
                            if (arr)
                            {
                                arr.push(item[4].itemid);
                            }
                            if (addarr)
                            {
                                addarr.push([item[4].itemid, item[1]]);
                            }
                        }
                        else if (this._cfgitems[item[0]])
                        {
                            if (item[0] == 240102100)
                            {
                                ModelProxy.change("movetips", "error", "系统检测到气血石，已经帮您自动使用");
                                PluginManager.instance.sendToServer("bag", CMDBag.UseItem, key);
                            }
                            this.cobj.name = this._cfgitems[item[0]].name;
                            this.cobj.count = item[1];
                            this.cobj.itemid = this._cfgitems[item[0]].itemid;
                            this.cobj.type = 1;
                            this.cobj.quality = this._cfgitems[item[0]].quality;
                            this.logShow(this.cobj);
                            if (arr)
                            {
                                arr.push(this._cfgitems[item[0]].itemid);
                            }
                            if (addarr)
                            {
                                addarr.push([item[0], item[1]]);
                            }
                        }
                    }
                    cfg;
                    if (this._cfgitems)
                    {
                        if (item && item[2] == 2)
                        {
                            cfg = this._cfgitems[item[0]];
                            item[4] = cfg;
                        }
                        else if (item && item[2] == 1)
                        {
                            flag;
                        }
                    }
                    item.index = key;
                    this.addItem = item;
                    bag[key] = item;
                    if (change)
                    {
                        PowerCheckControl.instance.check(item);
                    }
                    if (this._cfgitems[item[0]] && this._cfgitems[item[0]].itemtype == 2 && this._cfgitems[item[0]].cls == 4 && this._cfgitems[item[0]].bind != 1)
                    {
                        ModelProxy.change("mainui", "wdsj", null);
                    }
                }
            }
            if (moneyChange)
            {
                ModelProxy.change("store", "refresh", null);
                ModelProxy.change("npcdialog", "updatebag", null);
            }
            if (flag)
            {
                this.checkArms();
            }
            if (bag.emptycount <= 10)
            {
                if (this.guideFlag)
                {
                    this.guideFlag = false;
                    GuideView.getInstance().doGuide(GuideType.GUIDE_BB);
                    setTimeout(function () : void
            {
                guideFlag = true;
                return;
            }// end function
            , 1000 * 3 * 60);
                }
            }
            else
            {
                ModelProxy.change("guidepao", "hide", GuideType.GUIDE_BB);
            }
            ModelProxy.change("mainui", "checkDrug", null);
            if (change)
            {
                ModelProxy.change("mainview", "bagItemChange", null);
                ModelProxy.change("mainview", "SuperTF", null);
                ModelProxy.change("leftTishi", "setbagcount", null);
                ModelProxy.change("leftTishi", "useJingYanZhu", null);
                ModelProxy.change("union", "updateBag", null);
                ModelProxy.change("specialActivity", "updateBag", null);
                ModelProxy.change("mainui", "updateBagForActvieBtn", null);
                ModelProxy.change("store", "refresh", null);
                ModelProxy.change("mainui", "checkXunbaoShop", null);
                ModelProxy.change("baoshi", "updatebsfg", null);
                if (HandlerManager.instance.getHandler("skill"))
                {
                    (HandlerManager.instance.getHandler("skill") as NewSkillHandler).checkSkill();
                }
            }
            return;
        }// end function

        private function logShow(param1:Object) : void
        {
            if (param1.itemid == 240702351)
            {
                return;
            }
            if (this.logcount < 6)
            {
                ModelProxy.change("mainui", "newlogview", param1);
                var _loc_2:String = this;
                var _loc_3:* = this.logcount + 1;
                _loc_2.logcount = _loc_3;
            }
            return;
        }// end function

        public function updateCost(param1:int, param2:int, param3:Boolean = true, param4:Array = null, param5:Array = null) : void
        {
            var _loc_6:int = 0;
            var _loc_7:Array = null;
            var _loc_8:Object = null;
            var _loc_9:Point = null;
            var _loc_10:Point = null;
            var _loc_11:int = 0;
            var _loc_12:int = 0;
            if (param1 == 1)
            {
                if (param3)
                {
                    if (UserData.getBagData("gold") > param2)
                    {
                        this.cobj.name = this._cfgitems[6].name;
                        this.cobj.count = UserData.getBagData("gold") - param2;
                        this.cobj.itemid = this._cfgitems[6].itemid;
                        this.cobj.type = 2;
                        this.cobj.quality = this._cfgitems[6].quality;
                        this.logShow(this.cobj);
                    }
                    else if (UserData.getBagData("gold") < param2)
                    {
                        this.cobj.name = this._cfgitems[6].name;
                        this.cobj.count = param2 - UserData.getBagData("gold");
                        this.cobj.itemid = this._cfgitems[6].itemid;
                        this.cobj.type = 1;
                        this.cobj.quality = this._cfgitems[6].quality;
                        this.logShow(this.cobj);
                        if (param4)
                        {
                            param4.push(6);
                        }
                        if (param5)
                        {
                            param5.push([6, param2 - UserData.getBagData("gold")]);
                        }
                    }
                }
                ModelProxy.change("data", "bag.gold", param2);
            }
            else if (param1 == 2)
            {
                if (param3)
                {
                    if (UserData.getBagData("bonus") > param2)
                    {
                        this.cobj.name = this._cfgitems[2].name;
                        this.cobj.count = UserData.getBagData("bonus") - param2;
                        this.cobj.itemid = this._cfgitems[2].itemid;
                        this.cobj.type = 2;
                        this.cobj.quality = this._cfgitems[2].quality;
                        this.logShow(this.cobj);
                    }
                    else if (UserData.getBagData("bonus") < param2)
                    {
                        this.cobj.name = this._cfgitems[2].name;
                        this.cobj.count = param2 - UserData.getBagData("bonus");
                        this.cobj.itemid = this._cfgitems[2].itemid;
                        this.cobj.type = 1;
                        this.cobj.quality = this._cfgitems[2].quality;
                        this.logShow(this.cobj);
                        if (param4)
                        {
                            param4.push(2);
                        }
                        if (param5)
                        {
                            param5.push([2, param2 - UserData.getBagData("bonus")]);
                        }
                    }
                }
                ModelProxy.change("data", "bag.bonus", param2);
            }
            else if (param1 == 3)
            {
                if (param3)
                {
                    if (UserData.getBagData("money") > param2)
                    {
                        this.cobj.name = this._cfgitems[3].name;
                        this.cobj.count = UserData.getBagData("money") - param2;
                        this.cobj.itemid = this._cfgitems[3].itemid;
                        this.cobj.type = 2;
                        this.cobj.quality = this._cfgitems[3].quality;
                        this.logShow(this.cobj);
                    }
                    else if (UserData.getBagData("money") < param2)
                    {
                        this.cobj.name = this._cfgitems[3].name;
                        this.cobj.count = param2 - UserData.getBagData("money");
                        this.cobj.itemid = this._cfgitems[3].itemid;
                        this.cobj.type = 1;
                        this.cobj.quality = this._cfgitems[3].quality;
                        this.logShow(this.cobj);
                        if (param4)
                        {
                            param4.push(3);
                        }
                        if (param5)
                        {
                            param5.push([3, param2 - UserData.getBagData("money")]);
                        }
                    }
                }
                ModelProxy.change("xunbao", "updatemoney", null);
                ModelProxy.change("data", "bag.money", param2);
                ModelProxy.change("limitstore", "updateyuanbao", null);
            }
            else if (param1 == 4)
            {
                if (param3)
                {
                    if (UserData.getBagData("bgold") > param2)
                    {
                        this.cobj.name = this._cfgitems[1].name;
                        this.cobj.count = UserData.getBagData("bgold") - param2;
                        this.cobj.itemid = this._cfgitems[1].itemid;
                        this.cobj.type = 2;
                        this.cobj.quality = this._cfgitems[1].quality;
                        this.logShow(this.cobj);
                    }
                    else if (UserData.getBagData("bgold") < param2)
                    {
                        this.cobj.name = this._cfgitems[1].name;
                        this.cobj.count = param2 - UserData.getBagData("bgold");
                        this.cobj.itemid = this._cfgitems[1].itemid;
                        this.cobj.type = 1;
                        this.cobj.quality = this._cfgitems[1].quality;
                        this.logShow(this.cobj);
                        if (param4)
                        {
                            param4.push(1);
                        }
                        if (param5)
                        {
                            param5.push([1, param2 - UserData.getBagData("bgold")]);
                        }
                    }
                }
                ModelProxy.change("data", "bag.bgold", param2);
            }
            else if (param1 == 5)
            {
                if (param3)
                {
                    if (UserData.getBagData("jifen") > param2)
                    {
                        this.cobj.name = this._cfgitems[15].name;
                        this.cobj.count = UserData.getBagData("jifen") - param2;
                        this.cobj.itemid = this._cfgitems[15].itemid;
                        this.cobj.type = 2;
                        this.cobj.quality = this._cfgitems[15].quality;
                        this.logShow(this.cobj);
                    }
                    else if (UserData.getBagData("jifen") < param2)
                    {
                        this.cobj.name = this._cfgitems[15].name;
                        this.cobj.count = param2 - UserData.getBagData("jifen");
                        this.cobj.itemid = this._cfgitems[15].itemid;
                        this.cobj.type = 1;
                        this.cobj.quality = this._cfgitems[15].quality;
                        this.logShow(this.cobj);
                    }
                }
                ModelProxy.change("data", "bag.jifen", param2);
                ModelProxy.change("xunbao", "updatemoney", null);
                ModelProxy.change("mainui", "checkXunbaoShop", null);
                if (param2 == 0)
                {
                    ModelProxy.change("mainui", "removeBtn", "xunbaoshop");
                }
                else
                {
                    ModelProxy.change("mainui", "addBtn", "xunbaoshop");
                }
            }
            else if (param1 == 6)
            {
                if (param3)
                {
                    if (UserData.getBagData("intel") > param2)
                    {
                        this.cobj.name = this._cfgitems[7].name;
                        this.cobj.count = UserData.getBagData("intel") - param2;
                        this.cobj.itemid = this._cfgitems[7].itemid;
                        this.cobj.type = 2;
                        this.cobj.quality = this._cfgitems[7].quality;
                        this.logShow(this.cobj);
                    }
                    else if (UserData.getBagData("intel") < param2)
                    {
                        _loc_7 = new Array();
                        _loc_8 = UserData.getUserData();
                        _loc_9 = ModelProxy.getValue("data", "stagePos");
                        _loc_10 = ModelProxy.getValue("data", "itempoint");
                        _loc_11 = int(param2 - UserData.getBagData("intel"));
                        _loc_12 = 0;
                        if (_loc_11 >= 1 && _loc_11 <= 200)
                        {
                            _loc_12 = 1;
                        }
                        else if (_loc_11 >= 201 && _loc_11 <= 1000)
                        {
                            _loc_12 = 2;
                        }
                        else if (_loc_11 >= 1001)
                        {
                            _loc_12 = 3;
                        }
                        _loc_6 = 0;
                        while (_loc_6 < _loc_12)
                        {
                            
                            if (_loc_10 != null)
                            {
                                _loc_7.push({type:1, x:_loc_10.x, y:_loc_10.y});
                            }
                            _loc_6++;
                        }
                        this.cobj.name = this._cfgitems[7].name;
                        this.cobj.count = param2 - UserData.getBagData("intel");
                        this.cobj.itemid = this._cfgitems[7].itemid;
                        this.cobj.type = 1;
                        this.cobj.quality = this._cfgitems[7].quality;
                        this.logShow(this.cobj);
                        ModelProxy.change("mainui", "getRun", {type:CMDGetRun.INTELRUN, msgArr:[param2 - UserData.getBagData("intel")]});
                        if (param4)
                        {
                            param4.push(7);
                        }
                    }
                }
                ModelProxy.change("data", "bag.intel", param2);
            }
            else if (param1 == 8)
            {
                if (param3)
                {
                    if (UserData.getBagData("recy") > param2)
                    {
                        this.cobj.name = this._cfgitems[8].name;
                        this.cobj.count = UserData.getBagData("recy") - param2;
                        this.cobj.itemid = this._cfgitems[8].itemid;
                        this.cobj.type = 2;
                        this.cobj.quality = this._cfgitems[8].quality;
                        this.logShow(this.cobj);
                    }
                    else if (UserData.getBagData("recy") < param2)
                    {
                        this.cobj.name = this._cfgitems[8].name;
                        this.cobj.count = param2 - UserData.getBagData("recy");
                        this.cobj.itemid = this._cfgitems[8].itemid;
                        this.cobj.type = 1;
                        this.cobj.quality = this._cfgitems[8].quality;
                        this.logShow(this.cobj);
                    }
                }
                ModelProxy.change("data", "bag.recy", param2);
            }
            else if (param1 == 23)
            {
                if (param3)
                {
                    if (UserData.getBagData("flyuppower") > param2)
                    {
                        this.cobj.name = this._cfgitems[param1].name;
                        this.cobj.count = UserData.getBagData("flyuppower") - param2;
                        this.cobj.itemid = this._cfgitems[param1].itemid;
                        this.cobj.type = 2;
                        this.cobj.quality = this._cfgitems[param1].quality;
                        this.logShow(this.cobj);
                    }
                    else if (UserData.getBagData("flyuppower") < param2)
                    {
                        this.cobj.name = this._cfgitems[param1].name;
                        this.cobj.count = param2 - UserData.getBagData("flyuppower");
                        this.cobj.itemid = this._cfgitems[param1].itemid;
                        this.cobj.type = 1;
                        this.cobj.quality = this._cfgitems[param1].quality;
                        this.logShow(this.cobj);
                    }
                }
                ModelProxy.change("data", "bag.flyuppower", param2);
                ModelProxy.change("feishen", "GetFlyuppower", param2);
            }
            if (param1 > 1)
            {
                ModelProxy.change("store", "changemoney", {type:param1, count:param2});
            }
            return;
        }// end function

        private function checkArms() : void
        {
            var _loc_6:Object = null;
            var _loc_1:Array = [];
            var _loc_2:* = UserData.getBagData();
            var _loc_3:* = _loc_2.maxcount;
            var _loc_4:* = UserData.getUserData("level");
            var _loc_5:int = 1;
            while (_loc_5 <= _loc_3)
            {
                
                _loc_6 = _loc_2[_loc_5];
                if (_loc_6 && _loc_6[2] == 1)
                {
                    if (_loc_6[4].level < 40 && _loc_6[4].level < _loc_4)
                    {
                        _loc_6[4].index = _loc_5;
                        _loc_1.push(_loc_6[4]);
                    }
                }
                _loc_5++;
            }
            return;
        }// end function

        private function doSome(param1:int) : void
        {
            return;
        }// end function

    }
}
